package com.wanbatv.wangwangba;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.Menu;
import android.view.MenuItem;

import com.umeng.analytics.AnalyticsConfig;
import com.umeng.analytics.MobclickAgent;
import com.wanbatv.wangwangba.util.Behavior;


public class HuanyingActivity extends MonitorActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Behavior.onAppStart(this);
        setContentView(R.layout.activity_huanying);

        MobclickAgent.updateOnlineConfig(this);
        AnalyticsConfig.enableEncrypt(true);
    }

    @Override
    protected void onStart() {
        super.onStart();
        int defaultLoadingTime = 5000;
        boolean isEnter = getSharedPreferences("main", 0).getBoolean("isEnter",
                false);

        defaultLoadingTime = isEnter ? 5000 : defaultLoadingTime;
        new Handler().postDelayed(new Runnable() {
            public void run() {
                HuanyingActivity.this.finish();
                Intent intent = new Intent(HuanyingActivity.this, Login2Activity.class);
                startActivity(intent);
                finish();
            }
        }, defaultLoadingTime);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_huanying, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}
